﻿package com.content.model.LoadedAssets
{
	
	import flash.display.Loader;
	import flash.events.*;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.StyleSheet;
	import flash.utils.getDefinitionByName;
	
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;
	import org.puremvc.as3.utilities.startupmanager.interfaces.IStartupProxy;
	
	public class SkinProxy extends EntityProxy implements IStartupProxy
	{
		public static const NAME:String = 						"SkinProxy";
        public static const SRNAME:String = 					"SkinSRProxy";
		public static const LOAD_COMPLETE:String				= NAME + "-" + "LoadComplete";
		public static const LOAD_ERROR:String					= NAME + "-" + "LoadError";
		
		public function SkinProxy() 
		{
			super( NAME, null );
		}
		
		public function load() :void 
		{
//            sendNotification( AppFacade.SKIN_LOADING );
			
			var request:URLRequest = new URLRequest("assets/swf/skin.swf");
			var loader:Loader = new Loader();
			
			loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
			
			loader.load(request);
			
			data = loader;
        }
		
		private function loaderCompleteHandler(event:Event):void 
		{
			AssignClass();
			sendLoadedNotification( LOAD_COMPLETE, NAME, SRNAME );
		}
		
		private function errorHandler(e:IOErrorEvent):void 
		{
            sendLoadedNotification( LOAD_ERROR, NAME, SRNAME );
        }
		
		private function getAsset(assetName:String):Class{
			return Class(skin.contentLoaderInfo.applicationDomain.getDefinition(assetName));
		}
		
		private function get skin():Loader
        {
            return data as Loader;
        }
		
		public function GetClass(name:String):Class{
			return getAsset(name);
		}
		
		/**
		 * 加载进来的资源，以类的形式列举在此
		 */
		// ------------------------- IMG --------------------------------
		public static var IMG_SSliderOver:Class;
		public static var IMG_SSliderBG:Class;
		public static var IMG_SSlider:Class;
		public static var IMG_SArrowButton:Class;
		public static var IMG_Balken:Class;
		
		public static var IMG_BG_Framework:Class;
		public static var IMG_BG_MainPanel:Class;
		
		public static var IMG_CBar_BG_CBarL1:Class;
		public static var IMG_CBar_BG_CBarL2:Class;
		
		public static var IMG_MPHome_NoticeLogo:Class;
		public static var IMG_MPHome_RecommandBand:Class;
		
		public static var IMG_MPOLResCate_Title:Class;
		public static var IMG_MPOLResCate_Item:Class;
		public static var IMG_MPOLResCate_ItemActive:Class;
		public static var IMG_MPOLResCate_ArrowUp:Class;
		public static var IMG_MPOLResCate_ArrowDown:Class;
		
		public static var IMG_MPUserInfo_FormBG:Class;
		
		public static var TabItem:Class;
		
		// ------------------------- FlipPage --------------------------------
		public static var FlipPage_Shadow:Class;
		public static var FlipPage_Shade:Class;
		
		// ------------------------- Cart --------------------------------
		public static var IMG_BookShelf_BG:Class;
		public static var IMG_BookShelf_ArrowRight:Class;
		public static var IMG_BookShelf_ArrowLeft:Class;
		
		// ------------------------- PDFPlayer --------------------------------
		public static var TEMP_PDFPlayer:Class;
		
		// ------------------------- SoundPlayer --------------------------------
		public static var SoundPlayer_PlayerFrame:Class;
		
		// ------------------------- FlvPlayer --------------------------------
		public static var VideoPlayer_Mute:Class;
		public static var VideoPlayer_MuteLight:Class;
		public static var VideoPlayer_PlayButton:Class;
		public static var VideoPlayer_PlayButtonLight:Class;
		public static var VideoPlayer_Slider:Class;
		public static var VideoPlayer_SliderLight:Class;
		public static var VideoPlayer_PlayerBG:Class;
		public static var VideoPlayer_PlayerFrame:Class;
		public static var VideoPlayer_ProgressBarBG:Class;
		public static var VideoPlayer_VolumeRegion:Class;
		public static var VideoPlayer_GlowStick:Class;
		public static var VideoPlayer_VideoMask:Class;
		public static var VideoPlayer_VolumeBar:Class;
		
		// ------------------------- ICO --------------------------------
		public static var ICO_Arrow:Class;
		public static var ICO_Arrow_Active:Class;
		
		public static var ICO_CBar_Home:Class;
		public static var ICO_CBar_Home_Active:Class;
		public static var ICO_CBar_MyShelf:Class;
		public static var ICO_CBar_MyShelf_Active:Class;
		public static var ICO_CBar_OnlineRes:Class;
		public static var ICO_CBar_OnlineRes_Active:Class;
		public static var ICO_CBar_UserInfo:Class;
		public static var ICO_CBar_UserInfo_Active:Class;
		public static var ICO_CBar_Debug:Class;
		public static var ICO_CBar_Debug_Active:Class;
		public static var ICO_CBar_Setting:Class;
		public static var ICO_CBar_Setting_Active:Class;
		public static var ICO_CBar_Shutdown:Class;
		public static var ICO_CBar_Shutdown_Active:Class;
		public static var ICO_CBar_Audio:Class;
		public static var ICO_CBar_Book:Class;
		public static var ICO_CBar_Video:Class;
		
		public static var ICO_MP_BufferRing:Class;
		
		private function AssignClass():void{
			
		// ------------------------- IMG --------------------------------
			IMG_SSliderOver = getAsset("IMG_SSliderOver");
			IMG_SSliderBG = getAsset("IMG_SSliderBG");
			IMG_SSlider = getAsset("IMG_SSlider");
			IMG_SArrowButton = getAsset("IMG_SArrowButton");
			IMG_Balken = getAsset("IMG_Balken");
			
			IMG_BG_Framework = getAsset("IMG_BG_Framework");
			IMG_BG_MainPanel = getAsset("IMG_BG_MainPanel");
			
			IMG_CBar_BG_CBarL1 = getAsset("IMG_CBar_BG_CBarL1");
			IMG_CBar_BG_CBarL2 = getAsset("IMG_CBar_BG_CBarL2");
			
			IMG_MPHome_NoticeLogo = getAsset("IMG_MPHome_NoticeLogo");
			IMG_MPHome_RecommandBand = getAsset("IMG_MPHome_RecommandBand");
			
			IMG_MPOLResCate_Title = getAsset("IMG_MPOLResCate_Title");
			IMG_MPOLResCate_Item = getAsset("IMG_MPOLResCate_Item");
			IMG_MPOLResCate_ItemActive = getAsset("IMG_MPOLResCate_ItemActive");
			IMG_MPOLResCate_ArrowUp = getAsset("IMG_MPOLResCate_ArrowUp");
			IMG_MPOLResCate_ArrowDown = getAsset("IMG_MPOLResCate_ArrowDown");
			
			IMG_MPUserInfo_FormBG = getAsset("IMG_MPUserInfo_FormBG");
			
			TabItem = getAsset("TabItem");
			
		// ------------------------- FlipPage --------------------------------
			FlipPage_Shadow = getAsset("FlipPage_Shadow");
			FlipPage_Shade = getAsset("FlipPage_Shade");
			
		// ------------------------- Cart --------------------------------
			IMG_BookShelf_BG = getAsset("IMG_BookShelf_BG");
			IMG_BookShelf_ArrowRight = getAsset("IMG_BookShelf_ArrowRight");
			IMG_BookShelf_ArrowLeft = getAsset("IMG_BookShelf_ArrowLeft");
			
		// ------------------------- PDFPlayer --------------------------------
			TEMP_PDFPlayer = getAsset("TEMP_PDFPlayer");
			
		// ------------------------- SoundPlayer --------------------------------
			SoundPlayer_PlayerFrame = getAsset("SoundPlayer_PlayerFrame");
			
		// ------------------------- FlvPlayer --------------------------------
			VideoPlayer_Mute = getAsset("VideoPlayer_Mute");
			VideoPlayer_MuteLight = getAsset("VideoPlayer_MuteLight");
			VideoPlayer_PlayButton = getAsset("VideoPlayer_PlayButton");
			VideoPlayer_PlayButtonLight = getAsset("VideoPlayer_PlayButtonLight");
			VideoPlayer_Slider = getAsset("VideoPlayer_Slider");
			VideoPlayer_SliderLight = getAsset("VideoPlayer_SliderLight");
			VideoPlayer_PlayerBG = getAsset("VideoPlayer_PlayerBG");
			VideoPlayer_PlayerFrame = getAsset("VideoPlayer_PlayerFrame");
			VideoPlayer_ProgressBarBG = getAsset("VideoPlayer_ProgressBarBG");
			VideoPlayer_VolumeRegion = getAsset("VideoPlayer_VolumeRegion");
			VideoPlayer_GlowStick = getAsset("VideoPlayer_GlowStick");
			VideoPlayer_VideoMask = getAsset("VideoPlayer_VideoMask");
			VideoPlayer_VolumeBar = getAsset("VideoPlayer_VolumeBar");
			
		// ------------------------- ICO --------------------------------
			ICO_Arrow = getAsset("ICO_Arrow");
			ICO_Arrow_Active = getAsset("ICO_Arrow_Active");
			
			ICO_CBar_Home = getAsset("ICO_CBar_Home");
			ICO_CBar_Home_Active = getAsset("ICO_CBar_Home_Active");
			ICO_CBar_MyShelf = getAsset("ICO_CBar_MyShelf");
			ICO_CBar_MyShelf_Active = getAsset("ICO_CBar_MyShelf_Active");
			ICO_CBar_OnlineRes = getAsset("ICO_CBar_OnlineRes");
			ICO_CBar_OnlineRes_Active = getAsset("ICO_CBar_OnlineRes_Active");
			ICO_CBar_UserInfo = getAsset("ICO_CBar_UserInfo");
			ICO_CBar_UserInfo_Active = getAsset("ICO_CBar_UserInfo_Active");
			ICO_CBar_Debug = getAsset("ICO_CBar_Debug");
			ICO_CBar_Debug_Active = getAsset("ICO_CBar_Debug_Active");
			ICO_CBar_Setting = getAsset("ICO_CBar_Setting");
			ICO_CBar_Setting_Active = getAsset("ICO_CBar_Setting_Active");
			ICO_CBar_Shutdown = getAsset("ICO_CBar_Shutdown");
			ICO_CBar_Shutdown_Active = getAsset("ICO_CBar_Shutdown_Active");
			ICO_CBar_Audio = getAsset("ICO_CBar_Audio");
			ICO_CBar_Book = getAsset("ICO_CBar_Book");
			ICO_CBar_Video = getAsset("ICO_CBar_Video");
			
			ICO_MP_BufferRing = getAsset("ICO_MP_BufferRing");
			
		}

	}
}